Lock down perf
authorDavid Howells <dhowells@redhat.com>
Mon, 18 Feb 2019 12:45:02 +0000 (12:45 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Tue, 19 Nov 2019 01:43:33 +0000 (01:43 +0000)
Disallow the use of certain perf facilities that might allow userspace to
access kernel data.

Signed-off-by: David Howells <dhowells@redhat.com>
Gbp-Pq: Topic features/all/lockdown
Gbp-Pq: Name 0026-Lock-down-perf.patch

kernel/events/core.c

index 25769703db8a8494c433ef7aa659511e91104bfd..e07dff45c0509c5de2d19a307bc649f35f6e87f1 100644 (file)
@@ -10859,6 +10859,11 @@ SYSCALL_DEFINE5(perf_event_open,
                        return -EINVAL;
        }
 
+       if ((attr.sample_type & PERF_SAMPLE_REGS_INTR) &&
+           kernel_is_locked_down("PERF_SAMPLE_REGS_INTR"))
+               /* REGS_INTR can leak data, lockdown must prevent this */
+               return -EPERM;
+
        /* Only privileged users can get physical addresses */
        if ((attr.sample_type & PERF_SAMPLE_PHYS_ADDR) &&
            perf_paranoid_kernel() && !capable(CAP_SYS_ADMIN))